package com.wdzl.util;

import java.awt.*;

/**
 * 绘制罩影
 */
public class ShadowUtil {
    /**
     * 绘制照影
     */
    public static void drawShadow(Graphics g,int x,int y,int width,int height){
        int rule = AlphaComposite.SRC_OVER;
        float alpha = 0.8F;     //默认透明度
        drawShadow(g,x,y,width,height,alpha);
    }

    /**
     * 绘制罩影坐标位置，区域宽度高度。
     * @param g
     * @param x
     * @param y
     * @param width
     * @param height
     * @param alpha 透明度
     */
    public static void drawShadow(Graphics g,int x,int y,int width,int height,float alpha){
        int rule = AlphaComposite.SRC_OVER;
        ((Graphics2D) g).setComposite(AlphaComposite.getInstance(rule, alpha));
        g.fillRect(0,0,width,height);
    }
}
